<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="./common/header.jsp" %>
<head>
	<script charset="utf-8" src="${ctx}/js/kindeditor/kindeditor-min.js"></script>
	<script charset="utf-8" src="${ctx}/js/kindeditor/lang/zh_CN.js"></script>
	<script charset="utf-8" src="${ctx}/js/kindeditor/style/complex.js"></script>
	<style>
		#title_pic_list .title-pic{  
			width:150px;
		}
		.title-pic{
			position: relative;
		}
		
		.title-pic .del{
			position: absolute;
			left:0px;
			top:30px;
		}
		
		.title-pic .paixu{
			margin-bottom:15px;
		}
		
		.title-pic .paixu input{
			width:129px;
			border-radius:3px;
			border:1px solid #ccc;
			padding:2px 6px;
		}
		
		.title-pic .img{
			width:129px;
			height: 129px;
		}
	</style>
</head>
<body>
<%@ include file="./common/top.jsp"%>
	<div class="container"  id="mainContainer">
		<form class="form-horizontal" role="form" id="obj_form_id" name="obj_form">
		   
		  
		  <!-- begin 上传普通封面 -->
		  <div class="form-group" id="title_pic_list">
		  <label class="col-sm-2 control-label sr-only"></label>
		    <div class="col-sm-2 title-pic" style="display: none;" id="title_pic_model_id">
		    	<input type="hidden" class="name"/>
		    	<a href="#" class="del" title="删除图片"><img src="${ctx }/images/remove.png"></a>
		    	<div class="paixu"><input type="text" class="order-key"  placeholder="排序数字"/></div>
		    	<img class="img" src="../images/fmmb.png"/>
		    </div>
	
		  </div>
		  
		  <div class="form-group">
		    <label class="col-sm-2 control-label sr-only"></label>
		    <div class="col-sm-1">
		    	<input type="file" name="uploadFile" id="uploadify" />
		    </div>
		    <%--<div class="col-sm-4" style="line-height: 30px;">--%>
		    	<%--<span style="color:red;">(最多上传5张封面图片)</span>--%>
		    <%--</div>--%>
		    
		  </div>
		  
		  <!-- end 上传普通封面 -->
		  
		  <div class="form-group">
			    <label for="" class="col-sm-2 control-label"></label>
			    <div class="col-xs-3">
			    	<div id="add_fm_pic_url_a" href="#" class="btn btn-default">上传网络封面图片</div>
			    </div>
			  <div class="col-xs-2">
				  <div id="batch_add_fm_pic_url_a" href="#" class="btn btn-default">批量上传网络封面图片</div>
			  </div>
		  </div>
   
		  <div class="form-group">
		    <label for="" class="col-sm-2 control-label">标题</label>
		    <div class="col-xs-3">
		      <input name="goods.title" type="text" required-title="标题不能为空" class="form-control required useTitle">
		    </div>
		  </div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">连续未中次数</label>
				<div class="col-xs-3">
					<input name="goods.hard" value="0" type="number" required-title="连续未中次数不能为空" class="form-control required useTitle">
					<span style="line-height: 30px;font-size:10px;vertical-align: middle;">当该商品游戏次数达到设置次数时降低难度</span>
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">连续未中减少数量</label>
				<div class="col-xs-3">
					<input name="goods.hardNum" value="0" type="number" required-title="连续未中次数不能为空" class="form-control required useTitle">
					<span style="line-height: 30px;font-size:10px;vertical-align: middle;">达到连续未中次数后，降低通关数量</span>
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">连续未中减少时间</label>
				<div class="col-xs-3">
					<input name="goods.hardTime" value="0" type="number" required-title="连续未中次数不能为空" class="form-control required useTitle">
					<span style="line-height: 30px;font-size:10px;vertical-align: middle;">达到连续未中次数后，相应减少通关时间</span>
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">转盘速度</label>
				<div class="col-xs-3">
					<input name="goods.hardSpeed" value="0" type="number" required-title="转盘速度不能为空" class="form-control required useTitle">
					<span style="line-height: 30px;font-size:10px;vertical-align: middle;">为0表示采用系统默认速度，设置值为0.001到0.009之间，数字越大越快</span>
				</div>
			</div>
		  
		  <%--<div class="form-group">--%>
		    <%--<label for="" class="col-sm-2 control-label">使用媒体</label>--%>
		    <%--<div class="col-xs-3">--%>
		      <%--<input name="goods.keyword" type="text"   class="form-control">--%>
		    <%--</div>--%>
		  <%--</div> --%>
		  
		  <div class="form-group">
		    <label for="" class="col-sm-2 control-label">货号</label>
		    <div class="col-xs-3">
		      <input name="goods.item" type="text" required-title="货号不能为空" class="form-control required useTitle">
		    </div>
		  </div>
		  
		  <div class="form-group">
		    <label for="" class="col-sm-2 control-label">抢购描述</label>
		    <div class="col-xs-3">
			  <textarea name="content" style="width:700px;height:200px;visibility:hidden;"></textarea>
			  <input type="hidden" name="goods.content" id="content_id"/>
		    </div>
		  </div>
		  
		   <div class="form-group">
		    <label for="" class="col-sm-2 control-label">是否上架</label>
		    <div class="col-xs-3">
  		      <select name="goods.mark" class="form-control">
  		      	<option value="-1" >下架</option>
  		      	<option value="0" selected="selected">上架</option>
  		      </select>
		    </div>
		  </div>

			<%--<div class="form-group">--%>
				<%--<label for="" class="col-sm-2 control-label">是否为砍价商品</label>--%>
				<%--<div class="col-xs-3">--%>
					<%--<select name="goods.isKj" class="form-control">--%>
						<%--<option value="0" >否</option>--%>
						<%--<option value="1" selected="selected">是</option>--%>
					<%--</select>--%>
				<%--</div>--%>
			<%--</div>--%>

			<%--<div class="form-group">--%>
				<%--<label for="" class="col-sm-2 control-label">最低可砍价格</label>--%>
				<%--<div class="col-xs-3">--%>
					<%--<input name="goods.kjPrice" type="text" required-title="不能为空" class="form-control required useTitle">--%>
				<%--</div>--%>
			<%--</div>--%>
		   
		   <%--<div class="form-group">--%>
		    <%--<label for="" class="col-sm-2 control-label">客户服务</label>--%>
		    <%--<div class="col-xs-3">--%>
			  <%--<textarea name="goods.recommend" style="width:700px;height:40px;"></textarea>--%>
		    <%--</div>--%>
		  <%--</div>--%>
		  <%--<div class="form-group">--%>
		    <%--<label for="" class="col-sm-2 control-label">适合场景</label>--%>
		    <%--<div class="col-xs-3">--%>
			  <%--<textarea name="goods.scene" style="width:700px;height:40px;"></textarea>--%>
		    <%--</div>--%>
		  <%--</div>--%>
		  <%--<div class="form-group">--%>
		    <%--<label for="" class="col-sm-2 control-label">温馨提示</label>--%>
		    <%--<div class="col-xs-3">--%>
			  <%--<textarea name="goods.tips" style="width:700px;height:40px;"></textarea>--%>
		    <%--</div>--%>
		  <%--</div>--%>
		  
		  <%--<div class="form-group">--%>
		    <%--<label for="" class="col-sm-2 control-label">产品状态</label>--%>
		    <%--<div class="col-xs-3">--%>
  		      <%--<select name="goods.grade" required-title="请选择案例状态" class="form-control required useTitle">--%>
  		      	<%--<option value="">请选择</option>--%>
  		      	<%--<option value="1" selected="selected">名鞋折扣专场</option>--%>
  		      	<%--<option value="5">今日团购</option>--%>
  		      <%--</select>--%>
		    <%--</div>--%>
		  <%--</div>--%>
		  
		  
		  <%--<div class="form-group">--%>
		    <%--<label for="" class="col-sm-2 control-label">团购到期时间</label>--%>
		    <%--<div class="col-xs-3">--%>
		      <%--<input name="expiredDate" type="text"  class="form-control" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" >--%>
		    <%--</div>--%>
		  <%--</div>--%>
		  
		  <div class="form-group">
		    <label for="" class="col-sm-2 control-label">分类</label>
		    <div class="col-xs-3">
		      <select class="form-control required useTitle" required-title="请选择大分类" name="category.id" id="category_id">
					<option value="">请选择</option>
			  </select>
		    </div>
		  </div>
		  
		  <div class="form-group">
		    <label for="" class="col-sm-2 control-label">品牌</label>
		    <div class="col-xs-3">
		      <select class="form-control required useTitle" required-title="请选择大分类" name="goods.brandsId" id="brands_id">
					<option value="">请选择</option>
			  </select>
		    </div>
		  </div>
		  
		  <div id="color_div">
			   <div class="form-group">
			    <label for="" class="col-sm-2 control-label">颜色</label>
			    <div class="col-sm-10">
		 		   <label class="checkbox-inline">
					  <input type="checkbox" value=""  name="colorList[0].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[1].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[2].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[3].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[4].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[5].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[6].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[7].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[8].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[9].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[10].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[11].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[12].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[13].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[14].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[15].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[16].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[17].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[18].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[19].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[20].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[21].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[22].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[23].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[24].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[25].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[26].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[27].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[28].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[29].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="colorList[30].color" > 
					  <input class="form-control input-smm" type="text" value="" style="width:80px;"/>
					</label>
			    </div>
			  </div>
		  </div>
		 
		 <div class="form-group">
			    <div class="col-sm-offset-2 col-sm-10">
			      <div class="checkbox">
			        <label>
			         <input type="checkbox" id="check_all_size" > 选中36-45码
			        </label>
			      </div>
			    </div>
		  </div>
		  
		  <div id="size_div">
			   <div class="form-group">
			    <label for="" class="col-sm-2 control-label">尺码</label>
			    <div class="col-sm-10">
		 		   <label class="checkbox-inline">
					  <input type="checkbox" name="sizeList[0].size" value="" class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="36" style="width:80px;"/>
					</label>
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[1].size"  class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="36.5" style="width:80px;"/>
					</label>
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[2].size"  class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="37" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[3].size" class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="37.5" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[4].size" class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="38" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[5].size"  class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="38.5" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[6].size"  class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="39" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[7].size"  class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="40" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[8].size"  class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="40.5" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[9].size"  class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="41" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[10].size"  class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="42" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[11].size"  class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="42.5" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[12].size"  class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="43" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[13].size" class="offen-size"> 
					  <input class="form-control input-smm" type="text" value="44" style="width:80px;"/>
					</label>

					<label class="checkbox-inline">
						<input type="checkbox"  value=""  name="sizeList[14].size" class="offen-size">
						<input class="form-control input-smm" type="text" value="44.5" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[15].size" class="offen-size">
					  <input class="form-control input-smm" type="text" value="45" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[16].size" >
					  <input class="form-control input-smm" type="text" value="46" style="width:80px;"/>
					</label>
					
					<label class="checkbox-inline">
					  <input type="checkbox"  value=""  name="sizeList[17].size" >
					  <input class="form-control input-smm" type="text" value="46.5" style="width:80px;"/>
					</label>
					
			    </div>
			  </div>
		  </div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">游戏金币</label>
				<div class="col-xs-3">
					<input name="goods.gameNum" id="gameNum_id" type="number" validate-number-title="请输入数字" required-title="请输入游戏金币" maxlength="4" class="form-control required useTitle validate-number"/>
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">换购积分数量</label>
				<div class="col-xs-3">
					<input name="goods.integral" id="integral_id" type="number" validate-number-title="请输入数字" required-title="请输入换购积分数量" maxlength="4" class="form-control required useTitle validate-number"/>
				</div>
			</div>
		  
		   <div class="form-group">
		    <label for="" class="col-sm-2 control-label">原价</label>
		    <div class="col-xs-3">
  				<input name="goods.price" id="price_id" type="text" validate-number-title="请输入数字" required-title="请输入价格" maxlength="4" class="form-control required useTitle validate-number"/>
		    </div>
		  </div>
		  
		  <div class="form-group">
		    <label for="" class="col-sm-2 control-label">折扣</label>
		    <div class="col-xs-3">
			  <input name="goods.discount"  type="text" id="discount_id" required-title="请输入折扣" validate-number-title="请输入数字" maxlength="3" class="form-control required useTitle validate-number max-value-10 min-value-0" />
						<span style="line-height: 30px;font-size:10px;vertical-align: middle;">请输入0.0-10.0的数字</span>
		    </div>
		  </div>
		  
		  <div class="form-group">
		    <label for="" class="col-sm-2 control-label">现价</label>
		    <div class="col-xs-3">
  				<input name="goods.nowPrice" id="nowPrice_id" type="text" validate-number-title="请输入数字" required-title="请输入价格" maxlength="4" less-than-equal-title="请输入小等于原价的价格" class="form-control required useTitle validate-number less-than-equal-price_id"/>
		    </div>
		  </div>
		  
		  <div class="form-group">
		    <label for="" class="col-sm-2 control-label"></label>
		    <div class="col-xs-3">
			   <div class="alert alert-info">
			 		按住ctrl键可以多张一起上传,排序数字默认为文件名名称，比如文件名为1.jpg,那么排序数字默认为1，如果文件名非数字，排序默认为0
			   </div>
			   
			   <div class="alert alert-info">
			 		子图片数字越大排序越靠前面
			   </div>
		    </div>
		  </div>
		  
		  <div class="form-group">
				    <label for="" class="col-sm-2 control-label"></label>
				    <div class="col-xs-2">
				    	<div id="add_pic_url_a" href="#" class="btn btn-default">上传网络图片</div>
				    </div>  
				    <div class="col-xs-2">
				    	<div id="batch_add_pic_url_a" href="#" class="btn btn-default">批量上传网络图片</div>
				    </div> 
			    </div>
		  
		   <div class="form-group">
		    <label for="" class="col-sm-2 control-label">子图片</label>
		    <div class="col-xs-3">
			   <input type="file" name="uploadFile" id="uploadifySub" />
		    </div>
		    
		  </div>   
		  
		  <div id="sub_pic_model_id" style="margin-left:222px;" >
		  
		  </div>
		   
		   <div class="form-group">
		    <div class="col-sm-offset-2 col-sm-10">
	          <button id="add_obj_btn_id" type="button" class="btn btn-primary"><i class="glyphicon glyphicon-folder-close"></i>保存</button>
		      <a href="./index.jsp" class="btn btn-default">取消</a>
		    </div>
  		  </div>
  		  
  		</form>
	</div>
	
	<!-- begin子图片信息模板 -->
	<div id="sub_info_model" style="display: none;margin-top:15px;border:1px solid #ccc;">
		<div style="position: relative;">
			<a href="#" class="img-a">
				<img class="img" src="" style="height:100px;"/>
			</a>
			
			<a href="#" class="del" style="position: absolute;left:-12px;top:-12px;" title="删除图片"><img src="${ctx }/images/remove.png"/></a>
		</div>
		
		<input type="hidden" class="name"/>
		<input type="hidden" class="height"/>
		<input type="hidden" class="width"/>
		<input type="hidden" class="compressHeight"/>
		<input type="hidden" class="compressWidth"/>
		<input type="hidden" class="orderKey"/>
		<input type="hidden" class="size"/>
	</div>
	
	<!-- end子图片信息模板 -->
	
	<!-- begin添加网络封面图片 -->
	<div class="popup-modal" id="add_fm_urlpic_popup">
  			<form class="form-horizontal"  id="add_fm_url_pic_form">
	  			<label>封面http地址：</label>
	  			<input type="text" class="form-control input-sm"  id="pic_fm_url_id"/>
	  		</form>
 	</div>
  	<!-- end添加网络封面图片 -->

<!-- begin批量添加网络图片 -->
<div class="popup-modal" id="batch_add_fm_urlpic_popup">
	<form class="form-horizontal"  id="batch_add_fm_url_pic_form">
		<textarea rows="50" style="width:100%" id="batch_fm_textarea_id"></textarea>
	</form>
</div>

<!-- end批量添加网络图片 -->
  	
  	<!-- begin添加网络图片 -->
	<div class="popup-modal" id="add_urlpic_popup">
  			<form class="form-horizontal"  id="add_url_pic_form">
	  			<label>图片http地址：</label>
	  			<input type="text" class="form-control input-sm"  id="pic_url_id"/>
	  			<label>排序数字：</label>
	  			<input type="text" value="0" class="form-control input-sm"  id="pic_order_key_id"/>
	  		</form>
 	</div>
  		
  	<!-- end添加网络图片 -->
  	
  	<!-- begin批量添加网络图片 -->
	<div class="popup-modal" id="batch_add_urlpic_popup">
  			<form class="form-horizontal"  id="batch_add_url_pic_form">
	  			 <textarea rows="50" style="width:100%" id="batch_textarea_id"></textarea>
	  		</form>
 	</div>
  		
  	<!-- end批量添加网络图片 -->
	<script>
		var subPicNum = 0;
		$(function(){
			
			//绑定原价和现价blur事件
			$("#price_id,#nowPrice_id").blur(function(){
				var price = $("#price_id").val();
				var nowPrice = $("#nowPrice_id").val();
				if(price && nowPrice){
					var discount = nowPrice*10/price;
					discount = Math.round(discount*10)/10;
					$("#discount_id").val(discount);	
				}
				return false;
			});
			//绑定折扣事件
			$("#discount_id").blur(function(){
				var discount = $(this).val();
				var price = $("#price_id").val();
				var nowPrice = price*discount/10;
				if(price && nowPrice){
					nowPrice = Math.round(nowPrice); 
					$("#nowPrice_id").val(nowPrice);	
				}
				
				return false;
			});
			//验证重复颜色
			var validateColor = function(){
				var valid = true;
				var chooseColor = [];
				
				 $("#color_div").find(":checkbox:checked").each(function(){
					if($(this).val()){
						if($.inArray($(this).val(),chooseColor) != -1){
							window.top.jWei.Tips.error("存在多个"+$(this).val());
							chooseColor =null;
							valid = false;
							return false;
						}else{
							chooseColor.push($(this).val());
						}
					}
				});
				 return valid;
			};
			
			//验证重复尺码
			var validateSize = function(){
				var valid = true;
				var chooseSize = [];
				
				 $("#size_div").find(":checkbox:checked").each(function(){
					if($(this).val()){
						if($.inArray($(this).val(),chooseSize) != -1){
							window.top.jWei.Tips.error("尺码存在多个"+$(this).val());
							chooseSize =null;
							valid = false;
							return false;
						}else{
							chooseSize.push($(this).val());
						}
					}
				});
				 return valid;
			};
			//查询所有分类
			jQuery.ajax({
				type : 'Get',
				contentType : 'application/json',
				url : '../admin/category/getAll.do',
				dataType : 'json',
				success : function(data) {
					if (data.result) {
						var categoryList = data.obj;
						if(categoryList){
							for(var i = 0 ;i<categoryList.length;i++){
								var category = categoryList[i];
								if(category)
									$("#category_id").append("<option value="+category.id+">"+category.name+"</option>");
							}
						}
						
					} else {
						jWei.Tips.error("获取分类异常！");
					}
				},
				error : function(data) {
					
				}
			});	
			
			//查询所有品牌
			jQuery.ajax({
				type : 'Get',
				contentType : 'application/json',
				url : '../admin/brands/getAll.do',
				dataType : 'json',
				success : function(data) {
					if (data.result) {
						var brandsList = data.obj;
						if(brandsList){
							for(var i = 0 ;i<brandsList.length;i++){
								var brands = brandsList[i];
								if(brands)
									$("#brands_id").append("<option value="+brands.id+">"+brands.name+"</option>");
							}
						}
						
					} else {
						jWei.Tips.error("获取分类异常！");
					}
				},
				error : function(data) {
					
				}
			});	
			
			//绑定颜色事件
			$("#color_div").on("click",":checkbox",function(){
				$(this).val($(this).next().val());
				if($(this).prop("checked")){
					$(this).next()[0].select();
				}
			});
			
			$("#color_div").on("keyup",":text",function(){
				$(this).prev().val($(this).val());
			});
			
			//绑定尺码事件
			$("#size_div").on("click",":checkbox",function(){
				$(this).val($(this).next().val());
				if($(this).prop("checked")){
					$(this).next()[0].select();
				}
			});
			
			$("#size_div").on("keyup",":text",function(){
				$(this).prev().val($(this).val());
			});
			
			var valid = new jValidation.Validation('obj_form_id',{immediate:true},{onSubmit:false});
			
			//绑定保存按钮
			$('#add_obj_btn_id').click(
				function(){
					
					if(!validateColor()){
						return false;
					}
					
					if(!validateSize()){
						return false;
					}
					 
					var result = valid.validate();
					if(!result){
						return false;
					}
					
					if($("#user_avatar_id").val() == ""){
						window.top.jWei.Tips.error("请上传商品封面图片！");
						return;
					}
				
					$("#mainContainer").showLoading();
					//获取富文本编辑器内容
					var content = editor.html();
					$("#content_id").val(content);
					var formData = $('#obj_form_id').serialize();
					
					jQuery.ajax( {
						type : 'POST',
						url : '../admin/goods/add.do',
						dataType : 'json',
						data : formData,
						success : function(obj) {
							if(obj.result){
								window.top.jWei.Tips.success("操作成功！");
								window.location.href = "./index.jsp";
							}else{
								window.top.jWei.Tips.error(obj.errorMsg);
							}
							$("#mainContainer").hideLoading();
						},
						error : function() {
							window.top.jWei.Tips.error("数据库异常！");
						}
					});
				}		
			);
			
			//上传封面图片,最多5张
			var titlePicNum = 0;
			$("#uploadify").uploadify({
				height        : 30,
				swf           : '../styles/uploadify.swf',
				uploader      : '../admin/upload/add.do?jSessionid=9B16F7330BD01F6C96CB79971F36EA2B',
				buttonText    : '上传封面',  
				width         : 100,
				cancelImg     : '../images/uploadify-cancel.png',
				fileTypeExts   :'*.gif; *.jpg; *.png',
				onUploadSuccess:function(file, data, response){  
					// var size = $("#title_pic_list").find(".title-pic").size();
					// if(size >=6){
					// 	jWei.Tips.error("最多上传5张图片");
					// 	return;
					// }
					var dataObj = eval("("+data+")");
					var newDom = $("#title_pic_model_id").clone();
					newDom.attr("id","");
					newDom.find(".img").attr("src","../admin/upload/download.do?fileName="+dataObj.obj.name);
					newDom.find(".name").attr("name","titlePicList["+titlePicNum+"].name").val(dataObj.obj.name);
					newDom.find(".order-key").attr("name","titlePicList["+titlePicNum+"].orderKey").val(titlePicNum);
					$("#title_pic_list").append(newDom);
					newDom.show(); 
					titlePicNum++;
					// var size = $("#title_pic_list").find(".title-pic").size();
					//
					// if(size >=6){
					// 	$('#uploadify').uploadify('disable', true);
					// }
					
	        	} 
			});
			
			//绑定封面删除按钮
			$("#title_pic_list").on("click",".del",function(){
				$(this).closest(".title-pic").fadeOut(function(){
					$(this).remove();
					var size = $("#title_pic_list").find(".title-pic").size();
					if(size <6){
						$('#uploadify').uploadify('disable', false);
					}
				});
				return false;
			});
			//上传子图片
			$("#uploadifySub").uploadify({
				height        : 30,
				swf           : '../styles/uploadify.swf',
				uploader      : '../admin/upload/add.do?jSessionid=9B16F7330BD01F6C96CB79971F36EA2B',
				buttonText    : '上传子图片',  
				width         : 100,
				uploadLimit   : 1000, 
				removeCompleted: true,
				onUploadSuccess:function(file, data, response){  
					var dataObj = eval("("+data+")");
					var subPicInfo = $("#sub_info_model").clone();
	            	$('#sub_pic_model_id').append(subPicInfo);
	            	subPicInfo.find(".img").attr("src","../admin/upload/download.do?fileName="+dataObj.obj.name);
	            	subPicInfo.find(".img-a").attr("href","../admin/upload/download.do?fileName="+dataObj.obj.name).magnificPopup({type:'image'}).css("cursor","zoom-in");
	            	//设置图片名称
	            	var nameInput = subPicInfo.find(".name");
            	    nameInput.val(dataObj.obj.name);
            	    nameInput.attr("name","picList["+subPicNum+"].name");
            	    
            	    var heightInput = subPicInfo.find(".height");
            	    heightInput.val(dataObj.obj.height);
            	    heightInput.attr("name","picList["+subPicNum+"].height");
            	    
            	    var widthInput = subPicInfo.find(".width");
            	    widthInput.val(dataObj.obj.width);
            	    widthInput.attr("name","picList["+subPicNum+"].width");
            	    
            	    var compressHeightInput = subPicInfo.find(".compressHeight");
            	    compressHeightInput.val(dataObj.obj.compressHeight);
            	    compressHeightInput.attr("name","picList["+subPicNum+"].compressHeight");
            	    
            	    var compressWidthInput = subPicInfo.find(".compressWidth");
            	    compressWidthInput.val(dataObj.obj.compressWidth);
            	    compressWidthInput.attr("name","picList["+subPicNum+"].compressWidth");
            	    
            	    var sizeInput = subPicInfo.find(".size");
            	    sizeInput.val(dataObj.obj.size);
            	    sizeInput.attr("name","picList["+subPicNum+"].size");
            	    
            	    var orderKeyInput = subPicInfo.find(".orderKey");
            	    orderKeyInput.val(dataObj.obj.orderKey);
            	    orderKeyInput.attr("name","picList["+subPicNum+"].orderKey");
            	    subPicInfo.show();
            	    subPicNum++;
	        	},  
	        	 
	            onDel:function(file){
	            	if($("[srcName='"+file.name+"']"))
	            	$("[srcName='"+file.name+"']").remove();
	            }
			});
			
			$("#sub_pic_model_id").on("click",".del",function(){
				$(this).parent().parent().remove();
				return false;
			});
			
			//绑定选中36-44码事件
			$("#check_all_size").click(function(){
				var chk = $(this).prop("checked");
				 $(".offen-size").each(function(){
					 var chkSize = $(this).prop("checked");
					 if(chk != chkSize){
						 $(this).trigger("click");
					 }
				 });
			});
			
			//绑定添加网络封面图片按钮
			$("#add_fm_pic_url_a").click(function(){
                $("#pic_fm_url_id").val('');
				jWei.popUp({
					title:'上传网络封面图片',
					popUpId:'add_fm_urlpic_popup',
					width:'800px',
					ok:function(){
						if($("#pic_fm_url_id").val() == ''){
							jWei.Tips.error("图片地址不能为空！");
							$("#pic_fm_url_id").focus();
							return false;
						}
						  
						if(!$("#pic_fm_url_id").val().startsWith("http")){
							jWei.Tips.error("请填写以http开头的图片地址！"); 
							$("#pic_url_id").focus();
							return false;
						}
						// var size = $("#title_pic_list").find(".title-pic").size();
						// if(size >=6){
						// 	jWei.Tips.error("最多上传5张图片");
						// 	return;
						// }
						var newDom = $("#title_pic_model_id").clone();
						newDom.attr("id","");
						newDom.find(".img").attr("src",$("#pic_fm_url_id").val());
						newDom.find(".name").attr("name","titlePicList["+titlePicNum+"].name").val($("#pic_fm_url_id").val());
						newDom.find(".order-key").attr("name","titlePicList["+titlePicNum+"].orderKey").val(titlePicNum);
						$("#title_pic_list").append(newDom);
						newDom.show(); 
						titlePicNum++;
						// var size = $("#title_pic_list").find(".title-pic").size();
						//
						// if(size >=6){
						// 	$('#uploadify').uploadify('disable', true);
						// }
					}
				});
			});

            //绑定批量添加网络封面图片按钮
            $("#batch_add_fm_pic_url_a").click(function(){

                jWei.popUp({
                    title:'批量上传网络封面图片',
                    popUpId:'batch_add_fm_urlpic_popup',
                    width:'800px',
                    ok:function(){
                        if($("#batch_fm_textarea_id").val() == ''){
                            jWei.Tips.error("图片地址不能为空！");
                            $("#batch_fm_textarea_id").focus();
                            return false;
                        }

                        var urlS = $("#batch_fm_textarea_id").val();
                        var urlArr = urlS.split("https");

                        var index = 0;
                        for(var i = 0 ;i<urlArr.length;i++){
                            if(urlArr[i].indexOf(".jpg") != -1){
                                var newUrl  = "https"+urlArr[i];
                                index++;
                                var newDom = $("#title_pic_model_id").clone();
                                newDom.attr("id","");
                                newDom.find(".img").attr("src",newUrl);
                                newDom.find(".name").attr("name","titlePicList["+titlePicNum+"].name").val(newUrl);
                                newDom.find(".order-key").attr("name","titlePicList["+titlePicNum+"].orderKey").val(titlePicNum);
                                $("#title_pic_list").append(newDom);
                                newDom.show();
                                titlePicNum++;
                            }

                        }
                    }
                });
            });

            //绑定添加网络图片按钮
			$("#add_pic_url_a").click(function(){
				var oVal = $("#add_urlpic_popup").find("#pic_order_key_id").val();
				if(oVal>0){
					$("#add_urlpic_popup").find("#pic_order_key_id").val(parseInt(oVal)-1);
				}
				jWei.popUp({
					title:'上传网络图片',
					popUpId:'add_urlpic_popup',
					width:'800px',
					ok:function(){
						if($("#pic_url_id").val() == ''){
							jWei.Tips.error("图片地址不能为空！");
							$("#pic_url_id").focus();
							return false;
						}
						  
						if(!$("#pic_url_id").val().startsWith("http")){
							jWei.Tips.error("请填写以http开头的图片地址！"); 
							$("#pic_url_id").focus();
							return false;
						}
		            	 
						var subPicInfo = $("#sub_info_model").clone();
		            	$('#sub_pic_model_id').append(subPicInfo);
		            	subPicInfo.find(".img").attr("src",$("#pic_url_id").val());
		            	subPicInfo.find(".img-a").attr("href",$("#pic_url_id").val()).magnificPopup({type:'image'}).css("cursor","zoom-in");
		            	//设置图片名称
		            	var nameInput = subPicInfo.find(".name");
	            	    nameInput.val($("#pic_url_id").val());
	            	    nameInput.attr("name","picList["+subPicNum+"].name");
	            	    
	            	    var orderKeyInput = subPicInfo.find(".orderKey");
	            	    orderKeyInput.val($("#pic_order_key_id").val());
	            	    orderKeyInput.attr("name","picList["+subPicNum+"].orderKey");
	            	    subPicInfo.show();
	            	    subPicNum++;
					}
				});
			}); 
			
			//绑定批量添加网络图片按钮
			$("#batch_add_pic_url_a").click(function(){
				 
				jWei.popUp({
					title:'批量上传网络图片',
					popUpId:'batch_add_urlpic_popup',
					width:'800px',
					ok:function(){
						if($("#batch_textarea_id").val() == ''){
							jWei.Tips.error("图片地址不能为空！");
							$("#batch_textarea_id").focus();
							return false;
						} 
						
						var urlS = $("#batch_textarea_id").val();
						var urlArr = urlS.split("https");
						
						var index = 0;
						for(var i = 0 ;i<urlArr.length;i++){
							if(urlArr[i].indexOf(".jpg") != -1){
								var newUrl  = "https"+urlArr[i];
								index++;
								var subPicInfo = $("#sub_info_model").clone();
				            	$('#sub_pic_model_id').append(subPicInfo);
				            	subPicInfo.find(".img").attr("src",newUrl);
				            	subPicInfo.find(".img-a").attr("href",newUrl).magnificPopup({type:'image'}).css("cursor","zoom-in");
				            	//设置图片名称
				            	var nameInput = subPicInfo.find(".name");
			            	    nameInput.val(newUrl);
			            	    nameInput.attr("name","picList["+subPicNum+"].name");
			            	    
			            	    var orderKeyInput = subPicInfo.find(".orderKey");
			            	    orderKeyInput.val(index);
			            	    orderKeyInput.attr("name","picList["+subPicNum+"].orderKey");
			            	    subPicInfo.show();
			            	    subPicNum++;
							}
							
						}
					}
				});
			}); 
		});
	</script>
</body>


</html>